package com.blyat.xsoft.kernel.component.pool;

import com.google.common.base.Strings;

/**
 * @Auther: syh
 * @Date: 2020/8/4
 * @Description:
 */
public class URL {

    private String host;
    private int port;
    private String protocol;
    private String address;
    private long timeout;

    public URL(String host, int port, long timeout) {
        this.host = host;
        this.port = port;
        this.timeout = timeout;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getProtocol() {
        return protocol;
    }

    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public long getTimeout() {
        return timeout;
    }

    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }

    public String getRemoteAddress() {
        return Strings.isNullOrEmpty(address) ? String.format("%s:%s", host, port) : address;
    }
}
